<table border=0 width=100%>
    <TR><TD colspan="7"><h3>New Address in <u><TMPL_VAR name=group_name></u></h3></TD></TR>
    <tr>
        <TD>Salutation</TD>
        <TD>First Name</TD>
        <TD>Last Name</TD>
        <TD>Email Addr</TD>
        <TD>Company Name</TD>
        <TD>Company Name (short)</TD>
        <TD>Active</TD>
    </tr>
    <tr>
        <TD>
            <select id=salutation_id name=salutation_id style="width:100px;">
            <option value=0>--None--</option>
            <TMPL_LOOP name=SALUTATIONS>
                <option value="<TMPL_VAR name=salutation_id>"><TMPL_VAR name=salutation></option>
            </TMPL_LOOP>
            </select>
        </TD>
        <TD><input id=f_name name=f_name></TD>
        <TD><input id=l_name name=l_name></TD>
        <TD><input id=email_addr name=email_addr onblur="check_email_exists();"></TD>
        <TD><input id=company_name name=company_name></TD>
        <TD><input id=company_name_short name=company_name_short></TD>
        <TD><input type=checkbox id=active checked></TD>
    </tr>
    <tr>
        <TD colspan="5">
            <div id=ajaxresult></div>
        </TD>
        <td colspan="2">
            <input type=button id=action_new value='Add New User'
                    onClick="
                            CheckInputs();
                            InsertNew(
                            ['action__new', 
                            'salutation_id',
                            'f_name', 
                            'l_name', 
                            'email_addr', 
                            'active',
                            'company_name',
                            'company_name_short'], 
                            ['ajaxresult']);
                            resetForm();
                            RefreshRecipientList();">
            <TMPL_VAR name=newrecipient_ajax>
        </td>
    </tr>
</table>

<script>
URL = "addr.cgi";
shortcut.add('insert', function () {$('f_name').focus();});
function CheckInputs()
{
    if ($('f_name').value == '') {
        $('ajaxresult').value	= 'Please enter a valid email address';
        $('email_addr').focus();
        exit;
    }
}

function resetForm()
{
    $('f_name').value = '';
    $('l_name').value = '';
    $('email_addr').value = '';
    $('company_name').value = '';
    $('company_name_short').value = '';
    $('active').checked = true;
    $('f_name').focus();
}

function check_email_exists()
{
    if ($('email_addr').value == '') return;
    PARAMS  = "action=check_email_exists&email_addr=" + $('email_addr').value;
//     alert (URL + '..' + PARAMS);

    new Ajax.Updater ('ajaxresult', URL, {
                        parameters: PARAMS,
                        asynchronous: true,
                        onLoading: PrintStatus('ajaxresult', "Checking if email exists..."),
                        onComplete: ClearStatus,
                        });
}
</script>